package com.lawrence.common.except;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 自定义异常
 * @author wanglanglang
 */
@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@Api(tags = "统一异常返回")
public class CustomException extends RuntimeException {

    private static final long serialVersionUID = 4564124491192825748L;

    @ApiModelProperty(value = "状态码")
    private int code;

    public CustomException() {
        super();
    }

    public CustomException(int code, String message) {
        super(message);
        this.setCode(code);
    }

    int getCode() {
        return code;
    }

    private void setCode(int code) {
        this.code = code;
    }
}